package com.rimi.service.impl;

import com.rimi.bean.MenuAddress;
import com.rimi.bean.MenuTime;
import com.rimi.cache.AdminCache;
import com.rimi.dao.MenuTimeDao;
import com.rimi.service.MenuTimeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * InnoDB free: 11264 kB 服务实现类
 * </p>
 *
 * @author sky
 * @since 2018-06-06
 */
@Service
public class MenuTimeServiceImpl extends ServiceImpl<MenuTimeDao, MenuTime> implements MenuTimeService {
    @Autowired
    private AdminCache adminCache;
    @Autowired
    private MenuTimeService menuTimeService;

    /*从redis查询时间菜单列表*/
    public List<MenuTime> getMenuTimeList(){
        List MenuTime = adminCache.getCacheList("MenuTime", com.rimi.bean.MenuTime.class);
        //缓存中是否有数据
        if(MenuTime!=null&&!MenuTime.isEmpty()){
            return MenuTime;
        }
        //如果有数据
        List MenuTime1 = menuTimeService.selectList(null);
        //将查询结果缓存到redis中
        adminCache.addCacheList("MenuTime", MenuTime1);
        return MenuTime1;
    }

}
